5.1 Contour-based techniques for image segmentation¶
Image segmentation is the process of assigning a label to every pixel in an image such that pixels with the same label share certain characteristics. As a consequence, it produces regions whose pixels have similar properties (e.g. intensity, color, texture, or location in the image) which have a geometric and semantic meaning (see Fig.1). The result of image segmentation could be:
- a set of segments that collectively cover the entire image (e.g. thresholding),
- or a set of contours extracted from the image (e.g. edge detection).
Conceptually, two traditional approaches to image segmentation exist (see Fig. 2):
- Top-down segmentation (semantic segmentation), which considers that pixels from the same object in the scene should be in the same segmented region.
- Bottom-up segmentation (pixel-driven segmentation), which establishes that similar pixels in the image must be in the same segmented region. $\\[5pt]$
We put the spotlight here on bottom-up segmentation approaches. Methods following such approach can be grouped into:
- Contour-based techniques, which attempt to identify the image regions by detecting their contours.
- Region-based techniques that group together pixels that are similar.
In this book we are going to experience both, starting with contour-based techniques, whose are based on detecting specific contours in the image (e.g. circles). In this context, image contours are defined as edge pixels that enclose a region.
Contour-based techniques could be roughly classified into:
- Local tecniques. Try to segment regions by detecting closed contours, which typically enclose pixels with similar intensities.
- LoG + zero crossing.
- Edge following (Canny operator).
- Global techniques. Detect particular shapes in the image (circles, lines, etc.).
- Hough transform.
This notebook will cover the Hough transform (section 5.1.1), a contour-based technique that can be used for detecting regions with an arbitrary shape in images.
Problem context - Self-driving car¶
A prestigious company located at PTA (The Andalusia Technology Park) is organizing a hackathon for this year in order to motivate college students to make further progress in the autonomous cars field. Computer vision students at UMA decided to take part in it, but the organizers have posed an initial basic task to guarantee that participants have expertise in image processing techniques.
This way, the company sent to students a task for implementing a basic detector of road lane lines using OpenCV in python. We are lucky! These are two tools that we know well ;).
Detecting lines in a lane is a fundamental task for autonomous vehicles while driving on the road. It is the building block to other path planning and control actions like breaking and steering.
So here we are! We are going to detect road lane lines using Hough transform in OpenCV.$\\[5pt]$